home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Examples / CPlusExamples / DemoText / UDemoText.h < prev   
Encoding:
C/C++ Source or Header  |  1990-10-25  |  3.5 KB  |  121 lines  |  [TEXT/MPS ]

  1. /* Copyright © 1989 - 1990 by Apple Computer, Inc. All rights reserved. */
  2. /* UDemoText.p */
  3.  
  4.  
  5. /*
  6.     This sample application demonstrates the breadth of alternatives
  7.     available when using the MacApp building-block "UTEView" for text-editing.
  8. */
  9.  
  10. #ifndef __UDEMOTEXT__
  11. #define __UDEMOTEXT__
  12. #include "UMacApp.h"
  13. #include "UPrinting.h"
  14. #include "UTEView.h"
  15. #include "ToolUtils.h"
  16. #include "Fonts.h"
  17. #include "Resources.h"
  18. #include "Script.h"
  19. #include "Picker.h"
  20. #endif
  21.  
  22. const unsigned long kSignature            = 'SS04';        /* application signature */
  23. const unsigned long kFileType            = 'TEXT';        /* file-type code for saved disk files --
  24.                                                           uses standard text files */
  25. const short kWindowRsrcID        = 1004;                    /* 'view' template for a DemoText window */
  26. const short kViewRsrcID            = 1005;                    /* 'view' template for a DemoText view */
  27.  
  28.                                                         /* Additional document specifications */
  29. struct TextSpecs {
  30.     Str255 theTextFont;
  31.     Style theTextFace;
  32.     short theTextSize;
  33.     RGBColor theTextColor;
  34.     short theJustification;                                /* record justification */
  35.     RGBColor theBackColor;                                /* Window's background color */
  36. };
  37. typedef TextSpecs *TextSpecsPtr;
  38. typedef TextSpecsPtr *TextSpecsHdl;
  39.  
  40. class TDemoTextApplication : public TApplication {
  41.   public:
  42.  
  43.     virtual pascal void IDemoTextApplication(void);
  44.                 /* Initialize the Application */
  45.  
  46.     virtual pascal TDocument *DoMakeDocument(CmdNumber itsCmdNumber);
  47.                 /* Launches a TTextDocument */
  48.  
  49. #if  qDebug
  50.     virtual pascal void IdentifySoftware(void);
  51. #endif
  52.  
  53. };
  54.  
  55. class TTextDocument : public TDocument {
  56.   public:
  57.  
  58.     Handle fDocText;                                    /* The text owned by the document */
  59.     TEStyleHandle fStyles;                                /* Style handle, if any */
  60.     STHandle fElements;                                    /* Handle to element array, if any */
  61.     TTEView *fTEView;                                    /* The view which displays the text */
  62.  
  63.     TextSpecs fTextSpecs;                                /* Specifies properties of the text */
  64.  
  65.                         /* Initialization and freeing */
  66.  
  67.     virtual pascal void ITextDocument(void);
  68.     virtual pascal void Free(void);
  69.     virtual pascal void DoInitialState(void);
  70.     virtual pascal void FreeData(void);
  71.  
  72.                         /* Filing */
  73.  
  74.     virtual pascal void DoNeedDiskSpace(long *dataForkBytes, long *rsrcForkBytes);
  75.     virtual pascal void DoRead(short aRefNum, Boolean rsrcExists, Boolean forPrinting);
  76.     virtual pascal void DoWrite(short aRefNum, Boolean makingCopy);
  77.  
  78.                         /* Making views and windows */
  79.  
  80.     virtual pascal void DoMakeViews(Boolean forPrinting);
  81.  
  82.                         /* Command processing */
  83.  
  84.     virtual pascal TCommand *DoMenuCommand(CmdNumber aCmdNumber);
  85.     virtual pascal void DoSetupMenus(void);
  86.  
  87.                         /* Auxiliary routines */
  88.  
  89.     virtual pascal void ChangeBackColor(RGBColor *newColor);
  90.  
  91.     virtual pascal void SetSpecStyle(void);
  92.  
  93.     virtual pascal void ShowReverted(void);
  94.                 /* When the user reverts a document, this is called after reading
  95.                   the old document and before displaying it. Causes the reverted
  96.                   font specs to be installed. */
  97.  
  98.                 /* Debugging */
  99.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  100.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  101.  
  102. };
  103.  
  104. class TJustCommand : public TCommand {
  105.   public:
  106.     TTEView *fTEView;
  107.     short fOldJust;
  108.     short fNewJust;
  109.  
  110.     virtual pascal void IJustCommand(TTEView *itsTEView, short itsNewJust);
  111.  
  112.     virtual pascal void DoIt(void);
  113.  
  114.     virtual pascal void RedoIt(void);
  115.  
  116.     virtual pascal void UndoIt(void);
  117.  
  118.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  119.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  120. };
  121.